Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_decorated_box #3061

Merged
merged 3 commits into from
Nov 17, 2021
Merged

use_decorated_box #3061

merged 3 commits into from
Nov 17, 2021

Conversation

minhqdao
Copy link
Contributor

@minhqdao minhqdao commented Nov 13, 2021

Description

Use DecoratedBox over Container when only Decoration is specified.

Fixes #3060

Kind

Style advice.

Bad Example

Widget buildArea() {
  return Container(
    decoration: const BoxDecoration(
      color: Colors.blue,
      borderRadius: BorderRadius.all(
        Radius.circular(5),
      ),
    ),
    child: const Text('...'),
  );
}

Good Example

Widget buildArea() {
  return const DecoratedBox(
    decoration: BoxDecoration(
      color: Colors.blue,
      borderRadius: BorderRadius.all(
        Radius.circular(5),
      ),
    ),
    child: Text('...'),
  );
}

@google-cla google-cla bot added the cla: yes label Nov 13, 2021
Copy link
Member

@bwilkerson bwilkerson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the one missing test case, this looks good.

test_data/rules/use_decorated_box.dart Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Nov 16, 2021

Coverage Status

Coverage increased (+0.04%) to 94.172% when pulling c353612 on minhqdao:use-decorated-box into 0537764 on dart-lang:master.

Copy link
Member

@pq pq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. And thanks for kicking off the thoughtful corresponding conversation in #3060! 👍

Could you add an attribution for yourself in AUTHORS?

Thanks!

lib/src/rules/use_decorated_box.dart Outdated Show resolved Hide resolved
@pq pq merged commit 94b3a20 into dart-lang:master Nov 17, 2021
mockturtl added a commit to mockturtl/tidy that referenced this pull request Nov 24, 2021
- `no_leading_underscores_for_library_prefixes` dart-lang/linter#3062
- `no_leading_underscores_for_local_identifiers` dart-lang/linter#3062
- `secure_pubspec_urls` dart-lang/linter#3056
- `use_decorated_box` dart-lang/linter#3061
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Aug 23, 2023
* Add UseDecoratedBox

* Add missing tests

* Add to AUTHORS and nit description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

proposal: use_decorated_box
4 participants